﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" class="loading">
    <?php
					
					session_start();
					
					//if($_COOKIE["w"] && $_COOKIE["mb"])
					//{
						 
						//echo "<a class=\"backBtn\" href=\"javascript:history.go(-1);\">返回</a>";	
					//}
					//else
					//{
						//echo "<a class=\"backBtn\" href=\"login/login.html\">登录</a>";
					//}
					$actid=$_GET["actid"];
					require_once("../connectMysql/connetMysql.class.php");
					$db=new connetMysql;
					$con=$db->getConnect();
					$get_infosql="SELECT * FROM activity WHERE ActivityId='".$actid."'";	
					$result=$con->query($get_infosql);
					$row = mysqli_fetch_assoc($result);	
					$readNum=$row["ActRNum"]+1;
					$updateRN="UPDATE activity SET ActRNum=".$readNum." WHERE ActivityId=".$actid;
					$con->query($updateRN);
					$actstype=array(1=>"分享会","研讨会","路演会","众筹会","观影会","悦读会","发布会","博览会","展销会","招聘会","交流会","培训会","充电会","其他");
					$actcharge=array(1=>"免费",10=>"10元",20=>"20元",30=>"30元",40=>"40元",50=>"50元",60=>"60元",100=>"100元",200=>"200元",300=>"300元",2=>"其他",3=>"AA");
					
					$get_user_namesql="SELECT UserName FROM `user` WHERE UserId='".$row["Userid"]."'";	
					$result2 =mysqli_query($con,$get_user_namesql);
					$row2 = mysqli_fetch_assoc($result2);	
					
	?>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<meta name="viewport" content="width=device-width, initial-scale=0.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
	<meta name="keywords" content="新创社" />
	<meta name="description" content="新创社会创新">
	<meta name="author" content="新创社" />
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<meta content="telephone=no" name="format-detection">
	<title><?php echo $row["ActDescri"];?></title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/apply.js"></script>
	<link rel="stylesheet" type="text/css" href="../css/indexstyle.css" />
    <link rel="stylesheet" type="text/css" href="css/showactstyle.css" />
	<link rel="apple-touch-icon-precomposed" href="../img/default/defaultshare.jpg">
	<link href="../img/icons/favicon.ico" rel="shortcut icon" type="image/x-icon">
</head>
<body>
		<img src="../img/default/defaultshare.jpg" width="0" height="0" />
		<div style="display:none"><img src="../img/default/defaultshare.jpg" /></div>
        </div>
		<div class="head">
			<!-- Header -->
			<div id="header">
				<a id="menu" href="#menu"></a>
				<span id="Logo" class="svg">
					<img src="../img/icons/logo.png" />
				</span>
                <a class="backBtn" onclick='javascript:history.back()'>返回</a>
             
				
			</div>
            <!--End Header-->
            
            <input type="hidden" name="actid" id="actid" value="<?php echo $actid; ?>"/>
            
			<div class="subHeader"><i class="i-home i-small"></i>新创社会创新!</div>
			
		</div>
        <div class="main"  id="wrapper">  
             <div class="activity-detail">
             	  <div class="actcon">
                  	<h2 class="media-title"><?php echo $row["ActDescri"]; ?></h2>
                    <table class="mt top">
                        <tbody>
                        	<tr>
                              <td><span>热度 <?php echo $readNum; ?>°C</span></td>
                           	  <td class="topr">举报</td>
                        	</tr>
                   		</tbody></table>
                  </div>
                  
                  <div class="actcon">
                    <h3><?php echo $actstype[$row["ActType"]]?></h3>
                    <table class="mt info">
                        <tbody>
                        <tr>
                            <td style="width:80px;margin-left:10px;">活动发起：</td><td><a href="../me/me.php?userid=<?php echo $row["Userid"];?>"><?php echo $row2["UserName"]; ?></a></td>
                            <td rowspan="3">
                                <i class="fa fa-thumbs-o-up"></i>
                                <!--<p>3</p> -->
                            </td>
                        </tr>
                        <tr><td style="width:80px;margin-left:10px;">活动人数：</td><td> <?php echo $row["ActLimitNum"]; ?>人</td></tr>
                        <tr><td style="width:80px;margin-left:10px;">活动费用：</td><td><?php echo $actcharge[$row["ActCharge"]]; ?></td></tr>
                        <tr><td style="width:80px;margin-left:10px;">活动日期：</td><td><?php echo date('Y-m-d',strtotime($row["ActStart"])); ?></td></tr>
                        <tr><td style="width:80px;margin-left:10px;">活动区域：</td><td><?php echo $row["ActProv"].$row["ActCity"]; ?></td></tr>
                        <tr><td style="width:80px;margin-left:10px;">详细地址：</td><td><?php echo $row["ActAddress"]; ?></td></tr>
                    </tbody></table>
                    <br />
                    <br />
                    <h3>活动介绍</h3>
                    <p class="mt" style="line-height:1.5em;">
                    	<?php 
							echo str_replace("\r\n",'<br/>',$row["ActContent"]);
						?>
                    </p>
                        
                        <br />
                        <br />
                        <h3>已报名：<?php 
									
									$num_sql="SELECT * FROM actapply WHERE ActivityId='".$actid."'";	
									$result3=mysqli_query($con,$num_sql);
									$num=mysqli_affected_rows($con);
									echo $num;
									?>/<?php echo $row["ActLimitNum"]; ?>人&nbsp;</h3>
                        <table class="mt" id="event">
                        	<tbody>
                            <?php 
                            while ($row3 = mysqli_fetch_assoc($result3))
							{
								$get_aplyuser_namesql="SELECT UserName FROM `user` WHERE UserId='".$row3["UserId"]."'";	
								$result4 =$con->query($get_aplyuser_namesql);
								$row4 = mysqli_fetch_assoc($result4);	
								echo "<tr><td>".$row4["UserName"]."</td></tr>";
							}
							?>
                            	
                           </tbody>
                       </table>               
                </div>
                    <div class="clearfix mt" id="clearfix">
                    	<?php 
							
							if($num>$row["ActLimitNum"])
								echo "<input type=\"button\" disabled=\"disabled\" class=\"cks-btn fr\" value=\"名额已满\"/>";
							else if(empty($_SESSION["mb"]))
							{
								echo "<a href=\"../login/login.html\"><input type=\"button\" class=\"cks-btn fr\" value=\"我要报名\"/></a>";
							}
							else
							{
								$applypost_sql="SELECT UserId FROM user WHERE UserPhone=".$_SESSION["mb"];		
								$result5=mysqli_query($con,$applypost_sql);
								$row = mysqli_fetch_assoc($result5);	
								$userid=$row["UserId"];
								
								$chkapply_sql="SELECT ActApplyId FROM actapply WHERE UserId=".$userid." AND ActivityId=".$actid;	
								mysqli_query($con,$chkapply_sql);
								$applynum=mysqli_affected_rows($con);
								if($applynum!=0)
								{
									echo "<input type=\"button\" class=\"cks-btn fr\" id=\"apply\" value=\"取消报名\"/>";
								}
								else
									echo "<input type=\"button\" class=\"cks-btn fr\" id=\"apply\" value=\"我要报名\"/>";
							}
							
								
								
							$db->clossConnet();
						?>
                        <br />
                        <br />
                        
                        <div class="jiathis_style_m"></div>
                     
                          
                    </div>
             </div>      
        </div>

		<div class="foot">
    		<!-- Footer -->
            <section class="footer">
                <ul>
                    <li><a href="people/person.php"><img src="../img/icons/blog.png" width="18" height="26" alt="icon"><span>人</span></a></li>
                    <li><a href="../index.php"><img src="../img/icons/contact.png" width="27" height="26" alt="icon"/><span>约</span></a></li>
                   
                   	<li><a href="../me/me.php"><img src="../img/icons/about.png" width="25" height="26" alt="icon"/><span>我</span></a></li>
                 
                </ul>
            </section>

			<!--End Footer -->
    	</div>
<?php 
//function findname($con,$table,$id)
//{
	//$get_user_namesql="SELECT UserName FROM ".$table." WHERE UserId='".$id."'";	
	//$result =mysqli_query($con,$get_user_namesql);
	//$row = mysqli_fetch_assoc($result);	
	//return $row["UserName"];
//}
?>
<!-- JiaThis Button BEGIN -->

<script type="text/javascript" src="http://v3.jiathis.com/code/jiathis_m.js" charset="utf-8"></script>
<!-- JiaThis Button END -->
</body>

</html>